<script type="text/javascript">
	trit(window.parent.instance);
    function insert(file){
        $("#hinhanh", top.document).val(file);
        windowClose(); 
    }
</script>
<? 
    $seg2 = $this->router->fetch_method(); 
?>
    <div class="media-upload-header">
        <ul id="menu">
            <li><a href="<?=base_url()?>mod_file_manager/image_manager_editor/index" <?if($seg2=='index'){echo ' class="current"';}?>><?=lang('library');?></a></li>
            <li><a href="<?=base_url()?>mod_file_manager/image_manager_editor/upload" <?if($seg2=='upload'){echo ' class="current"';}?>><?=lang('upload_file');?></a></li>
        </ul>
    </div>
    <div class="form_upload">
        <div align="center" style="padding-top: 20px;">
            <?=form_open_multipart('mod_file_manager/image_manager_editor/upload');?>
                <table class="form">
                    <tr>
                        <td colspan="2"><?php if(!empty($message)) echo "<div style='border:1px solid #fdb735; background-color: #e9ffef; padding:10px;margin-bottom:10px'>".$message."</div>";?>
                            <? if($this->session->flashdata('message')){
                                echo '<div class="message">'.$this->session->flashdata('message').'</div>';
                            }if($this->session->flashdata('error')){
                                echo '<div class="error">'.$this->session->flashdata('error').'</div>';
                            }if($this->session->flashdata('notes')){
                                echo '<div class="notes">'.$this->session->flashdata('notes').'</div>';
                            } ?>
                        </td>
                    </tr>
                    <tr>
                        <td class="required label"><?=lang('category_image');?></td>
                        <td class="">
                            <select class="w300" name="image_category_id">
                                <!--<option value="">Category</option>-->
                                <?php foreach($list_category as $category){
                                    echo '<option value="'.$category->image_category_id.'">'.$category->image_category_name.'</option>';
                                }?>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td class="label"><?php echo lang('image_name');?></td>
                        <td><input class="w300" type="text" name="lb_title" value=""/></td>
                    </tr>
                     <tr style="display:none;">
                        <td class="label"><?php echo lang('image_description');?></td>
                        <td><textarea class="w300" name="description"></textarea></td>
                    </tr>
                    <tr>
                        <td class="label"><?=lang('choose_file_upload');?></td>
                        <td>
                            <input  type="file" name="filedata">
                            <input type="hidden" name="id" value="1">
                            <input type="submit" name="upload" value="Upload">
                        </td>
                    </tr>
                </table> 
            <?=form_close();?>
        </div>
    <? if(isset($file_name)){?>
        <table class="site">
            <tr>
                <td><a id="closelink" href="#" onclick="insertImage('<?=base_url_site().'uploads/images/'.$str_dir.'/'.$file_name?>','');"><img src="<?=base_url_site().'uploads/images/'.$str_dir.'/'.$file_name?>" height="50" alt=""></a></td>
                <td style="width: 70px"><a id="closelink" href="#" onclick="insertImage('<?=base_url_site().'uploads/images/'.$str_dir.'/'.$file_name?>','');"><b><?=lang('choose_file');?></b></a></td>
            </tr>
        </table>
    <?}?>
    </div>